package com.mgfireworks.mgplatform.mgadmin.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.hn.java.summer.db.BaseDao;
import cn.hn.java.summer.db.multiple.DataSource1;

import com.mgfireworks.mgplatform.mgadmin.comm.IncreaseIdService;
import com.mgfireworks.mgplatform.mgadmin.sys.model.Organization;

/**
 * 
 * @author nap
 * 20161015-10:19:48
 * 机构业务类
 */
@Service
public class OrganizationService extends BaseDao<DataSource1>{
	
	@Autowired
	IncreaseIdService increaseIdService;
	
	/**
	 * 取机构列表
	 * @return
	 */
	public List<Organization> getOrganizations(Organization p){
		return list("getOrganizations",Organization.class,p);
	}

	/**
	 * 添加机构
	 */
	public void addOrganization(Organization p){
		update("addOrganization",p);
	}
	
	/**
	 * 修改机构
	 */
	public void editOrganization(Organization p){
		update("editOrganization",p);
	}
	
	/**
	 * 删除机构
	 */
	public void delOrganization(Organization p){
		update("delOrganization",p);
	}
	
	/**
	 * 取机构
	 */
	public Organization getOrganization(Organization p){
		return get("getOrganization",Organization.class,p);
	}
	
	/**
	 * 获取一个新机构
	 * @return
	 */
	public Organization newOrganization(){
		return new Organization(increaseIdService.getNewOrganizationId());
	}
}